<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
      *{
      list-style: none;
      margin: 0;
      padding: 0;
    }
    img{
        width: 200px;
        height: 50px;
        object-fit: cover;
    }
    ul {
        width: 400%;
        height: 50px;
    }
    ul li{
        float:left
    }
    .main{
        width: 200px;
        height: 50px;
        background: red;
        position: relative;
    
    }
    .lefta{
        width: 10px;
        height: 10px;
        background: black;
        position:absolute;
        top: 45%;
    }
    .leftb{
        width: 10px;
        height: 10px;
        background: black;
        position:absolute;
        top: 45%;
        right:0;
    }
    .circle{
      position:absolute;
      bottom: 0px;
      left: 78px;
    }
    .current{
        background:red !important;
    }
    .circle li{
        width: 10px;
        height: 10px;
        background: black;
      border-radius: 50% 50%;
        float:left;
    }
    </style>
<body>
    <div class="main">
        <div href="#" class="lefta"></div>
        <div href="#" class="leftb"></div>
        <ul>
            <li>
                <a href="#"><img src="../css篇/mountain.jpg"></a>
            </li>
            <li>
                <a href="#"><img src="../css篇/2.png"></a>
            </li>
            <li>
                <a href="#"><img src="../css篇/mountain.jpg"></a>
            </li>
      
        </ul>
        <ol class="circle">
            <!-- <li>

            </li>
            <li>
                
            </li>
            <li>
                
            </li> -->
        </ol>
    </div>
</body>
<script src="./animate.js"></script>
<script>
    var ul=document.querySelector('ul')
    var ol=document.querySelector('ol')
    for(var i=0;i<ul.children.length;i++){
        var li =document.createElement('li')
        li.setAttribute('index',i)
        ol.appendChild(li)
        li.addEventListener('click',function(){
            for(var i=0;i<ol.children.length;i++){
                ol.children[i].className=''
            }
            this.className='current';
            index=this.getAttribute('index')
            ul.style.marginLeft=(-index*200)+'px'
            num=index
            circle=index
        })
    }
    document.querySelector('ol').children[0].className='current'; 
    var first  = ul.children[0].cloneNode(true)
    ul.appendChild(first)
    var num=0;
    var circle=0;
    document.querySelector('.leftb').addEventListener('click',function(){
        if(num==3){
            ul.style.marginLeft=0+'px'
            num=0;
        }
        num++
        ul.style.marginLeft=(-num*200)+'px' 
        circle++;
        if(circle==3)
            circle=0;
        for(var i=0;i<ol.children.length;i++){
                ol.children[i].className=''
            }
            ol.children[circle].className='current';
    })
</script>

</html>
